package com.sp.fresh_produce.common;

/**
 * 通用类型返回API对象
 */
public class GenericReturnApiObject {
    private int status;
    private String msg;
    private Object data;

    public GenericReturnApiObject() {
    }

    public GenericReturnApiObject(int status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public GenericReturnApiObject(int status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /**
     * 成功返回
     */
    public static GenericReturnApiObject success(Object data) {
        return new GenericReturnApiObject(1000, "SUCCESS", data);
    }
    public static GenericReturnApiObject success() {
        return new GenericReturnApiObject(1000, "SUCCESS");
    }

    /**
     * 失败返回（使用 code + message，避免对外部类型的硬依赖）
     */
    public static GenericReturnApiObject fail(int code, String message) {
        return new GenericReturnApiObject(code, message, null);
    }
}
